<template>
  <view class="program-view">
    <block v-if="isReadyState">
      <ApplianceLayout full :page-style="pageStyle" :header-style="headerStyle">
        <!-- 顶部 -->
        <view class="top-container display-center">
          <CoverPicture style="margin-top: 80rpx" :src="coverImage" />
          <view class="extra-btn">
            <AsideControl
              icon="/pages/appliance/static/TurnOn.png"
              icon-active="/pages/appliance/static/TurnOn.png"
              :actived="powerActived"
              @change="onPowerChange"
            />
            <AsideControl title="童锁状" desc="已关闭" desc-active="已开启" :actived="childLock" />
            <AsideControl
              v-if="control.store.childLockSet !== -1"
              title="童锁设"
              desc="已关闭"
              desc-active="已开启"
              :actived="childLockSet"
              @change="lockToggle"
            />
            <AsideControl
              v-if="control.store.childLockInHotWater !== -1"
              title="60度童"
              desc="已关闭"
              desc-active="已开启"
              :actived="childLockInHotWater"
              @change="childLockInHotWaterToggle"
            />
            <AsideControl
              title="程序切"
              desc="不下发"
              desc-active="下发"
              :actived="isPostOptions"
              @change="changePostOptions"
            />
          </view>
        </view>
        <!-- 程序选择 -->
        <view class="program-list-box" :class="{ disabled: powerOff }">
          <view class="group-box" v-for="(group, groupIndex) in programGroups" :key="groupIndex">
            <view class="program-group">{{ group.name }}</view>
            <view class="program-list">
              <view
                class="program"
                v-for="(program, programIndex) in group.programs"
                :class="{ active: currentProgramKey === program.key }"
                :key="programIndex"
                @click="selectedProgram(program, programIndex)"
                >{{ program.name }}</view
              >
            </view>
          </view>
        </view>

        <template #action-bar>
          <ActionButton text="调节参数" :disabled="powerOff" @click="adjustParameter" />
        </template>

        <!-- 调节参数 -->
        <PageModal
          v-model:show="adjustParameterVisible"
          :page-style="pageModalStyle"
          :footer-size="footerSize"
          :footer-style="footerStyle"
          @close="closeModal"
        >
          <view class="adjust-params">
            <view class="adjust-title">{{ currentProgramName }}</view>
            <view class="adjust-desc" v-if="currentProgramDes">{{ currentProgramDes }}</view>
            <view class="adjust-parameter-grid">
              <view v-for="grid in parameterGrids" :key="grid.key" class="grid-item" :class="{ fullrow: !grid.isHalf }">
                <ParameterCard
                  :title="grid.title"
                  :type="grid.type"
                  :option-key="grid.key"
                  :value="grid.value"
                  :unit="grid.unit"
                  :options="grid.options"
                  :programKey="currentProgramKey"
                  @change="changeOptionsValue"
                />
              </view>
            </view>
          </view>

          <template #footer>
            <ActionButton vibrate :disabled="powerOff" @click="startProgramNow">
              <view>{{ $t('Appliance.AdjustParameter.StartProgram.Button.Text') }}</view>
            </ActionButton>
          </template>
        </PageModal>

        <NoticeBar :control="control" />
      </ApplianceLayout>
    </block>

    <!-- 机器状态 -->
    <StateView
      v-if="!isReadyState"
      :control="control"
      :custom-state-getter="customStateGetter"
      @action="onStateAction"
    />

    <!-- 错误提示 -->
    <Modal v-model:visible="errorHint" :description="errorTxt" ok-text="知道了"></Modal>

    <!-- 开关机提示框 -->
    <Modal
      v-model:visible="powerTipsVisible"
      description="当前型号不支持开关机控制"
      ok-text="我知道了"
      @ok="powerTipsVisible = false"
    />
  </view>
</template>

<script lang="ts">
type SubmitOptionType = { key: string; value: number | string }
</script>

<script setup lang="ts">
import ApplianceLayout from '@/layout/appliance/index.vue'
import CoverPicture from '../../view/control/components/CoverPicture.vue'
import AsideControl from '../../view/control/components/AsideControl.vue'
import ActionButton from '@/common/actionButton/actionButton.vue'
import Modal from '@/common/modal.vue'
import PageModal from '@/common/pageModal.vue'
import ParameterCard, { type Option, type ValueType } from '../../components/parameterCard.vue'
import StateView, { type StateAction } from '../../view/stateView.vue'
import NoticeBar from '../../view/notification/noticeBar.vue'

import type { BIWDController } from '@/controller/BIWD/definition'
import { actionDebounce } from '@/utils/mpHelper'
import netconfig from '@/config/netconfig'
import type { submitDataType, submitSettingType } from '../favoriteList/favoriteList.vue'
import {
  BIWD_WATERTREATMENT_CHILDLOCKHIGHTEMPERATURE,
  ChildLockSet,
  DatConfig,
  DatConfig_Set,
  DatConfig_SetCollect,
  OperationState,
  RoomTemp,
} from '@/constants/WDCommand'
import { setHomeAppliancePrograms, setHomeApplianceSettings } from '@/api/appliance'
import {
  getNewProgramScope,
  getNewProgramAvailable,
  type ProgramsGroupListType,
  type AvailableProgramType,
  type ProgramsOptionsType,
  type EnumValuesType,
} from '@/api/biwd'
import { footerStyle, footerSize } from '@/layout/appliance/style'
import type { ParameterGrid } from '../../view/adjustParameterView.vue'
import type { CustomConfigGetter, StateViewConfig } from '../../view/stateView.vue'
import type { Remote } from '@/controller/base/types/remote'
import type { WS } from '@/utils/socket/types'
import { BSH_OVEN_PROGRAM_SELECTED } from '@/constants/Command'
import { cloneDeep } from 'lodash'

const pageStyle = {
  backgroundColor: '#f4f4f6',
}
const pageModalStyle = {
  backgroundColor: '#ffffff',
}
const headerStyle = {
  backgroundColor: '#f4f4f6',
}

const haId = computed(() => props.control.store._datasource.haId)
const vib = computed(() => props.control.store._datasource.vib)
const isNewSetType = computed(() => !['WS7060BB1C', 'WS7061BB1C', 'WBB8060B1C'].includes(vib.value))
const coverImage = computed(() => `${netconfig.PHOTO_IMAGE}${vib.value}/${vib.value}.png`)
const coolWaterSwitch = computed(() => props.control.store.coolWaterSwitch)
const operateState = computed(() => props.control.store.operateState)
const childLock = computed(() => props.control.store.childLock === 1)
const childLockSet = computed(() => props.control.store.childLockSet == 1)
const childLockInHotWater = computed(() => props.control.store.childLockInHotWater === 1)
const programGroups = ref<ProgramsGroupListType[]>([])
const isReadyState = computed(() => ['Ready', 'Standby', 'Error'].includes(operateState.value))
const powerOff = computed(() => operateState.value === 'Standby')
const roomTemp = ref('')

const isPostOptions = ref(false) // 是否下发参数
// 错误提示
const errorHint = ref(false)
const errorTxt = ref('')

const props = defineProps<{
  control: BIWDController.Control
}>()

onBeforeMount(() => {
  if (['Ready', 'Standby', 'Run'].includes(operateState.value)) {
    getProgramScopeFun()
  }
  listenMessages()
})

/**
 * 获取所有程序
 */
async function getProgramScopeFun() {
  const res = await getNewProgramScope(haId.value)
  programGroups.value = res.data.programGroup
  getApplianceDetails()
}

/**
 * 获取当前程序详细信息
 */
async function getApplianceDetails() {
  const res = await getNewProgramAvailable(haId.value)
  if (res.code === 0 || res.code === 950004) {
    if (res.data.programs && res.data.programs.length > 0) {
      currentProgram.value = res.data.programs[0]
      currentProgramKey.value = res.data.programs[0].key
      currentProgramName.value = res.data.programs[0].name
      currentProgramOptions.value = res.data.programs[0].options
      currentProgramDes.value = String(res.data.programs[0].desc || '')
      parameterGrids.value = getParameterGrids(res.data.programs[0].options)
    }
  }
}

/**
 * 获取调节参数
 */
const parameterGrids = ref<ParameterGrid[]>([])
function getParameterGrids(options: ProgramsOptionsType[]): ParameterGrid[] {
  const grids: ParameterGrid[] = []

  options.forEach((option: ProgramsOptionsType) => {
    if (isPickerGrid(option)) {
      grids.push(getPickerGrid(option))
    } else if (isRadioGrid(option)) {
      grids.push(getRadioGrid(option))
    }
  })

  return grids
}
function isPickerGrid(option: ProgramsOptionsType) {
  return option.type === 'scope'
}
function isRadioGrid(option: ProgramsOptionsType) {
  // 枚举类型
  return option.type === 'enum'
}
function getPickerGrid(option: ProgramsOptionsType): ParameterGrid {
  let selectOptions = getNumberOptions(option)

  return {
    key: option.key,
    title: option.name,
    unit: option.unit,
    type: 'Picker',
    options: selectOptions,
    value: option.value + '',
  }
}
function getRadioGrid(option: ProgramsOptionsType): ParameterGrid {
  let selectOptions: Option[] = getEnumOptions(option)

  return {
    key: option.key,
    title: option.name,
    unit: option.unit,
    type: 'Radio',
    options: selectOptions,
    value: option.value + '',
  }
}
function getNumberOptions(option: ProgramsOptionsType): Option[] {
  const min = Number(option.min)
  const max = Number(option.max)

  const step = Number(option.step) || 1 // 步进
  const selectOptions: Option[] = []

  for (let i = 0; min + i * step <= max; i++) {
    const stepValue = min + i * step
    const labelValue = min + i * step
    selectOptions.push({
      label: labelValue + '',
      value: stepValue + '',
      key: option.key,
    })
  }
  return selectOptions
}
function getEnumOptions(option: ProgramsOptionsType): Option[] {
  if (!option.enumValues || option.enumValues.length === 0) return []
  let enumValues = option.enumValues
  return enumValues.map((value) => ({
    label: value.name + '',
    value: value.machineValue + '',
    key: option.key + '',
  }))
}
function changeOptionsValue(key: string, value: ValueType) {
  return
  if (Number(value) === 65535) {
    errorTxt.value = '手机端不支持切换连续出水'
    errorHint.value = true
    return
  }

  let newCurrentOptions = makeUpOptionsInDefault(
    Number(currentProgram.value && currentProgram.value.param),
    parameterGrids.value
  )
  let findIndex = newCurrentOptions.findIndex((item) => item.key === key)
  if (findIndex !== -1) {
    newCurrentOptions[findIndex].value = value as string
  }
  let submitData = {
    key: currentProgramKey.value,
    options: newCurrentOptions,
    settings: [],
  }
  showSendCommandLoading(submitData, key, value as string, '发送中', 3)
  setHomeAppliancePrograms(haId.value, submitData)
}

/**
 * 开关
 */
const powerActived = computed(() => !['Standby', 'Run'].includes(operateState.value || ''))
const powerTipsVisible = ref(false)
const onPowerChange = actionDebounce({
  call: async () => {
    powerTipsVisible.value = true
    // let settings: submitSettingType[] = []
    // if (isNewSetType.value) {
    //   settings = []
    // } else {
    //   settings = [
    //     {
    //       key: DatConfig,
    //       value: DatConfig_Set,
    //     },
    //   ]
    // }
    // if (powerOff.value) {
    //   settings.push({
    //     key: OperationState,
    //     value: 'BSH.Common.Status.OperationState.Ready',
    //   })
    //   showSendCommandLoading(settings, OperationState, 1, '正在开机')
    // } else {
    //   settings.push({
    //     key: OperationState,
    //     value: 'BSH.Common.Status.OperationState.Standby',
    //   })
    //   showSendCommandLoading(settings, OperationState, 0, '正在关机')
    // }
    // await setHomeApplianceSettings(haId.value, settings)
  },
})

/**
 * 调节参数
 */
const adjustParameterVisible = ref(false)
async function adjustParameter() {
  adjustParameterVisible.value = true
}
function closeModal() {
  adjustParameterVisible.value = false
}

/**
 * 选择程序
 */
const currentProgramKey = ref('')
const currentProgramName = ref('')
const currentProgram = ref<AvailableProgramType | null>(null)
const currentProgramOptions = ref<ProgramsOptionsType[]>([])
const currentProgramDes = ref('')
const selectedProgram = actionDebounce({
  call: async (program: AvailableProgramType, programIndex: number) => {
    return
    if (currentProgramKey.value === program.key) return
    if (!coolWaterSwitch.value && program.key == 'WaterTreatment.BIWD.Program.General.IceWater') {
      errorTxt.value = '当前冰水关闭，不支持切换'
      errorHint.value = true
      return
    }

    let optionList = getOptionsDefault(programGroups.value[0].programs[programIndex].options)
    if (!isPostOptions.value) {
      optionList = []
    }

    let submitData: submitDataType = {
      key: '',
      options: [],
      settings: [],
    }
    if (isNewSetType.value) {
      submitData = {
        key: program.key,
        options: optionList,
        settings: [],
      }
    } else {
      submitData = {
        key: program.key,
        options: optionList,
        settings: [
          {
            key: DatConfig,
            value: DatConfig_Set,
          },
        ],
      }
    }
    showSendCommandLoading(submitData, 'WaterTreatment.BIWD.Program.General', Number(program.param), '发送中', 3)
    setHomeAppliancePrograms(haId.value, submitData)
  },
})

/**
 *  获取当前程序options默认值
 */
function getOptionsDefault(optionsList: ProgramsOptionsType[]) {
  let optionList: SubmitOptionType[] = []
  optionsList.forEach((item) => {
    const option = {
      key: '',
      value: '',
    }
    switch (item.key) {
      case 'BSH.Common.Option.Operation':
        break
      case RoomTemp:
        break
      default:
        option.key = item.key
        option.value = String(item.default)
        if (option.key && option.value) {
          optionList.push(option)
        }
        break
    }
  })
  return optionList
}

/**
 * 组成options(未切换操作)
 */
function makeUpOptionsInDefault(param: number, options: ParameterGrid[]) {
  let optionList: SubmitOptionType[] = []
  if (!options || options.length === 0) {
    return optionList
  }
  for (let index = 0; index < options.length; index++) {
    const option = {
      key: '',
      value: '',
    }
    const sourceOption = options[index]
    switch (sourceOption.key) {
      case 'BSH.Common.Option.Operation': // 可运行操作
        break
      case RoomTemp: //室温
        break
      default:
        option.key = sourceOption.key
        option.value = String(sourceOption.value)
        if (option.key && option.value) {
          optionList.push(option)
        }
    }
  }
  return optionList
}

/**
 * 立即启动
 */
async function startProgramNow() {
  return
  if (childLock.value) {
    errorTxt.value = '童锁打开不支持出水'
    errorHint.value = true
    return
  }

  let submitData: submitDataType = {
    key: '',
    options: [],
    settings: [],
  }
  if (isNewSetType.value) {
    submitData = {
      key: currentProgramKey.value,
      options: [],
      settings: [
        {
          key: OperationState,
          value: 'BSH.Common.Status.OperationState.Run',
        },
      ],
    }
  } else {
    submitData = {
      key: currentProgramKey.value,
      options: [],
      settings: [
        {
          key: DatConfig,
          value: DatConfig_Set,
        },
        {
          key: OperationState,
          value: 'BSH.Common.Status.OperationState.Run',
        },
      ],
    }
  }

  let isContinuousWater = false
  parameterGrids.value.forEach((item) => {
    if (
      ['BSH.Common.Option.WaterVolume', 'WaterTreatment.BIWD.Option.FillQuantity'].includes(item.key) &&
      Number(item.value) === 65535
    ) {
      isContinuousWater = true
    }
    submitData.options.push({
      key: item.key,
      value: item.value + '',
    })
  })

  if (isContinuousWater) {
    errorTxt.value = '手机端不支持切换连续出水'
    errorHint.value = true
    return
  }

  setHomeAppliancePrograms(haId.value, submitData)
  closeModal()
}

/**
 * stateView 状态
 */
type NewContentsType = {
  label: string
  value: string
}
watch(
  () => operateState.value,
  (operateState) => {
    if (operateState !== 'Ready' && adjustParameterVisible.value) {
      adjustParameterVisible.value = false
    }
    if (['Standby', 'Ready'].includes(operateState)) {
      getProgramScopeFun()
    }
  }
)
const powerName = computed(() => (powerOff.value ? '开机' : '关机'))
const customStateGetter: CustomConfigGetter = (currentState, defaultGetter) => {
  let config: StateViewConfig = defaultGetter(currentState)
  if (operateState.value == 'Run') {
    let newContents: NewContentsType[] = []
    let newOptions = orderOptions(currentProgramOptions.value)
    newOptions.forEach((item) => {
      newContents.push({
        label: item.name as string,
        value:
          item.type === 'enum'
            ? (getOptionNameValue(item.value as string, item.enumValues) as string)
            : String(item.value),
      })
    })
    config = {
      title: '正在运行...',
      contents: newContents,
      actions: [{ name: '停止', event: 'stop-program', vibrate: true }],
    }
  } else if (operateState.value == 'ProgramFinished') {
    config = {
      title: '出水完成',
      contents: [],
      actions: [{ name: powerName.value, event: 'power-on-off', vibrate: true }],
    }
  } else if (operateState.value == 'Rinsing') {
    config = {
      title: '冲洗中',
      contents: [],
      actions: [],
    }
  } else if (operateState.value == 'ActionRequired') {
    config = {
      title: '程序运行异常,请前往家电端查看具体情况',
      contents: [],
      actions: [{ name: powerName.value, event: 'power-on-off', vibrate: true }],
    }
  }
  return config
}
function onStateAction() {
  let settings: { key: string; value: string }[] = []
  if (operateState.value == 'Run') {
    if (isNewSetType.value) {
      settings = [
        {
          key: OperationState,
          value: 'BSH.Common.Status.OperationState.ProgramFinished',
        },
      ]
    } else {
      settings = [
        {
          key: DatConfig,
          value: DatConfig_Set,
        },
        {
          key: OperationState,
          value: 'BSH.Common.Status.OperationState.ProgramFinished',
        },
      ]
    }
    setHomeApplianceSettings(haId.value, settings)
  } else {
    onPowerChange()
  }
}
const orderOptionsList = [
  'WaterTreatment.BIWD.Option.WaterTemperature',
  'WaterTreatment.BIWD.Option.FillQuantity',
  'BSH.Common.Option.WaterTemp',
  'BSH.Common.Option.WaterVolume',
]
function orderOptions(list: ProgramsOptionsType[]) {
  let newList: ProgramsOptionsType[] = []
  orderOptionsList.forEach((item) => {
    list.forEach((option) => {
      if (item === option.key) {
        newList.push(option)
      }
    })
  })
  return newList
}

/**
 * 获取运行阶段option显示value
 */
function getOptionNameValue(value: string, enumValues?: EnumValuesType[]) {
  if (!enumValues || enumValues.length === 0) return ''
  return enumValues.find((item) => Number(item.machineValue) === Number(value))?.name || ''
}

/**
 * 处理msg
 */
function listenMessages() {
  props.control.remote.addBatchObserves(observes)
}
const observeSettingKeys = computed(() => [
  BSH_OVEN_PROGRAM_SELECTED,
  'WaterTreatment.BIWD.Program.General',
  'BSH.Common.Option.WaterTemp',
  'BSH.Common.Option.WaterVolume',
  'WaterTreatment.BIWD.Option.FillQuantity',
  'WaterTreatment.BIWD.Option.WaterTemperature',
  RoomTemp,
  OperationState,
  ChildLockSet,
  BIWD_WATERTREATMENT_CHILDLOCKHIGHTEMPERATURE,
])
const observes: Remote.BatchObserve<BIWDController.Store>[] = [
  {
    matcher: (msg) => observeSettingKeys.value.includes(msg.key),
    handler: (msg, remote, msgContext) => handleMsg(msg, msgContext?.timestamp || 0),
  },
]
/**
 * 监听信息
 * @param item
 * @returns
 */
function handleMsg(item: WS.MessageItem, timestamp: number) {
  console.error('handleMsg', item)
  if (!item) {
    return
  }
  switch (item.key) {
    case BSH_OVEN_PROGRAM_SELECTED:
    case 'WaterTreatment.BIWD.Program.General':
      if (Number(currentProgram.value?.param) === Number(item.value)) {
        return
      }
      if (adjustParameterVisible.value) {
        adjustParameterVisible.value = false
        parameterGrids.value = []
      }
      getApplianceDetails()
      break
    case 'BSH.Common.Option.WaterTemp':
    case 'BSH.Common.Option.WaterVolume':
    case 'WaterTreatment.BIWD.Option.FillQuantity':
    case 'WaterTreatment.BIWD.Option.WaterTemperature':
      handleChangeOption(item)
      break
    case RoomTemp:
      roomTemp.value = item.value as string
      break
    default:
      break
  }
  if (isCallApi.value) {
    if (callApiInfo.value?.returnBshKey == item.key && callApiInfo.value?.returnBshValue == item.value) {
      hiddenSendCommandLoading()
    }
  }
}

/**
 * 选择参数变更
 * @param item
 */
function handleChangeOption(item: WS.MessageItem) {
  let options = cloneDeep(parameterGrids.value)
  options.forEach((option) => {
    if (option.key === item.key) option.value = item.value + ''
  })
  let currentOptions = cloneDeep(currentProgramOptions.value)
  currentOptions.forEach((option) => {
    if (option.key === item.key) option.value = item.value + ''
  })

  parameterGrids.value = options
  currentProgramOptions.value = currentOptions
}

/**
 * 展示showSendCommandLoading弹框
 * @param commandData 所发送的指令
 * @param returnBshKey websocket推送的key
 * @param returnBshValue websocket推送的value
 * @param text 加载弹框的文本
 * @param timeout 超时时间
 * @param timeoutFunction 超时后调用0:homeappliance和1:settings接口
 */
const isCallApi = ref(false)
type CallApiInfoType = {
  commandData: any
  returnBshKey: string
  returnBshValue: number | string
  nextAction: string
}
const callApiInfo = ref<CallApiInfoType | null>(null)
let callApiTimer: number | undefined
function showSendCommandLoading(
  commandData: any,
  returnBshKey: string,
  returnBshValue: number | string,
  text = '加载中',
  timeout = 3,
  timeoutFunction = () => {},
  nextAction = ''
) {
  if (isCallApi.value) {
    return
  }
  callApiInfo.value = {
    commandData,
    returnBshKey, // 机器端应返回的bshkey
    returnBshValue, // 机器端应返回的bshvalue
    nextAction, // 下一步执行的指令
  }
  isCallApi.value = true
  uni.showLoading({
    title: text,
    mask: true,
  })
  callApiTimer = setTimeout(() => {
    timeoutFunction()
    uni.showToast({
      icon: 'none',
      title: '网络超时',
    })
    hiddenSendCommandLoading()
  }, timeout * 1000)
}
/**
 * 关闭加载弹框
 */
function hiddenSendCommandLoading() {
  callApiInfo.value = {
    commandData: {},
    returnBshKey: '',
    returnBshValue: '',
    nextAction: '',
  }
  isCallApi.value = false
  clearTimeout(callApiTimer)
  uni.hideLoading()
}

/**
 * 是否下发参数切换
 */
function changePostOptions() {
  isPostOptions.value = !isPostOptions.value
}

/**
 * 切换童锁设置
 */
function lockToggle() {
  let settings = []
  if (isNewSetType.value) {
    settings = [
      {
        key: ChildLockSet,
        value: childLockSet.value
          ? 'WaterTreatment.BIWD.Setting.ChildLockSet.Off'
          : 'WaterTreatment.BIWD.Setting.ChildLockSet.On',
      },
    ]
  } else {
    settings = [
      {
        key: DatConfig,
        value: DatConfig_SetCollect,
      },
      {
        key: ChildLockSet,
        value: childLockSet.value
          ? 'WaterTreatment.BIWD.Setting.ChildLockSet.Off'
          : 'WaterTreatment.BIWD.Setting.ChildLockSet.On',
      },
    ]
  }

  showSendCommandLoading(settings, ChildLockSet, childLockSet.value ? '0' : '1', '正在设置')
  setHomeApplianceSettings(haId.value, settings)
}

/**
 * 60度童锁
 */
function childLockInHotWaterToggle() {
  let settings = []

  if (isNewSetType.value) {
    settings = [
      {
        key: BIWD_WATERTREATMENT_CHILDLOCKHIGHTEMPERATURE,
        value: childLockInHotWater.value ? 'FALSE' : 'TRUE',
      },
    ]
  } else {
    settings = [
      {
        key: DatConfig,
        value: DatConfig_SetCollect,
      },
      {
        key: BIWD_WATERTREATMENT_CHILDLOCKHIGHTEMPERATURE,
        value: childLockInHotWater.value ? 'FALSE' : 'TRUE',
      },
    ]
  }

  showSendCommandLoading(
    settings,
    BIWD_WATERTREATMENT_CHILDLOCKHIGHTEMPERATURE,
    childLockInHotWater.value ? '0' : '1',
    '正在设置'
  )
  setHomeApplianceSettings(haId.value, settings)
}
</script>

<style lang="less">
@import '@/styles/common.less';
@import '../style/programView.less';
</style>
